# Get the index of the specific columncategorical_columns <-c("SEX", "RACE", "ETHNIC","EXTRT", "RSSTRESC", "AEDECOD_MS", "AEBODSYS", "AESER", "TRT01P")
Code
# combine all the columnstest_columns <-c(numercial_quntile_columns, categorical_columns)test_columns
'LDH_quantile'
'ALB_quantile'
'HGB_quantile'
'EXDOSE_quantile'
'BMI_quantile'
'ECOG_quantile'
'CRP_quantile'
'TOTAE_quantile'
'SAECOUNT_quantile'
'AGE_quantile'
'SEX'
'RACE'
'ETHNIC'
'EXTRT'
'RSSTRESC'
'AEDECOD_MS'
'AEBODSYS'
'AESER'
'TRT01P'
Code
# doing the above for all the names left# initialize the p value tablep_values <-data.frame(variable =character(), pval =numeric())plots <-list()for (column in test_columns) { km_fit <-survfit(Surv(AVAL, 1- CNSR) ~get(column), data = data) plot1 <-ggsurvplot(km_fit, data = data, risk.table =TRUE, pval =TRUE, conf.int =TRUE,xlab ="Time (days)", ylab ="Survival Probability",title =paste("Kaplan-Meier Survival Curve by", column))# store p value in a variable p_1 <-surv_pvalue(km_fit, data=data)# store the plot into a list plots <-c(plots, list(plot1)) p_1$variable <- column# stack the p value p_values <-rbind(p_values, p_1)}# show the plotsfor (plot in plots) {print(plot)}print(p_values)
variable pval method pval.txt
1 LDH_quantile 0.82818591 Log-rank p = 0.83
2 ALB_quantile 0.53685880 Log-rank p = 0.54
3 HGB_quantile 0.45719761 Log-rank p = 0.46
4 EXDOSE_quantile 0.45194543 Log-rank p = 0.45
5 BMI_quantile 0.27818407 Log-rank p = 0.28
6 ECOG_quantile 0.22569470 Log-rank p = 0.23
7 CRP_quantile 0.92108310 Log-rank p = 0.92
8 TOTAE_quantile 0.06034994 Log-rank p = 0.06
9 SAECOUNT_quantile 0.97553802 Log-rank p = 0.98
10 AGE_quantile 0.27471230 Log-rank p = 0.27
11 SEX 0.17715902 Log-rank p = 0.18
12 RACE 0.34587291 Log-rank p = 0.35
13 ETHNIC 0.33172974 Log-rank p = 0.33
14 EXTRT 0.92144158 Log-rank p = 0.92
15 RSSTRESC 0.44755898 Log-rank p = 0.45
16 AEDECOD_MS 0.40835738 Log-rank p = 0.41
17 AEBODSYS 0.90328591 Log-rank p = 0.9
18 AESER 0.78180192 Log-rank p = 0.78
19 TRT01P 0.47909679 Log-rank p = 0.48
We used Kaplan-Meier curves to identify potential predictors of PFS. The following variables were selected based on the log-rank test.